Ext.regController('ArticleController',{
   
    'index': function (options) {
    	sessionStorage.clear();
    	
        if (!Reesenews.views.mainView) {
            Reesenews.views.mainView = new Reesenews.views.MainView();
        }
        else{
        	banner = 'reesenewsBanner';
        	
        	Ext.apply(Reesenews.views, {
        		articleListView : new Reesenews.views.ArticleListView({
        			articleStore : Reesenews.stores.articleStore
        		}),
        	});
        }
        Reesenews.views.mainView.setActiveItem(
         Reesenews.views.articleListView
        );
    },
    'sports': function(options){
    	sessionStorage.clear();
    	banner = 'reesenewsSport';

        Ext.apply(Reesenews.views, {
            articleListView : new Reesenews.views.ArticleListView({
                articleStore : Reesenews.stores.sportsStore
            }),

        });
        Reesenews.views.mainView.setActiveItem(
           Reesenews.views.articleListView
        );
    },
    'tech':function(options){
    	sessionStorage.clear();
    	banner = 'reesenewsTech';
        Ext.apply(Reesenews.views, {
            articleListView : new Reesenews.views.ArticleListView({
                articleStore : Reesenews.stores.techStore
            }),
        });
        Reesenews.views.mainView.setActiveItem(
           Reesenews.views.articleListView
        );
    },
    'town':function(options){
    	sessionStorage.clear();
    	banner = 'reesenewsTown';
        Ext.apply(Reesenews.views, {
            articleListView : new Reesenews.views.ArticleListView({
                articleStore : Reesenews.stores.townStore
            }),
        });
        Reesenews.views.mainView.setActiveItem(
           Reesenews.views.articleListView
        );
    },
    'campus':function(options){
    	sessionStorage.clear();
    	banner = 'reesenewsCampus';
        Ext.apply(Reesenews.views, {
            articleListView : new Reesenews.views.ArticleListView({
                articleStore : Reesenews.stores.campusStore
            }),
        });
        Reesenews.views.mainView.setActiveItem(
           Reesenews.views.articleListView
        );
    },
    'viewarticle': function (options) {
    	var currentArticle = options.article;
    	Ext.apply(Reesenews.views, {
    		articleView: new Reesenews.views.ArticleView({article: currentArticle})
        });
    	   Reesenews.views.mainView.items.add(Reesenews.views.articleView);
           Reesenews.views.mainView.setActiveItem(
                    Reesenews.views.articleView
        );
    },
    
    'submit': function(options){
    	Ext.apply(Reesenews.views, {
    		submissionsView: new Reesenews.views.SubmissionView()
        });
    	Reesenews.views.mainView.items.add(Reesenews.views.submissionsView);
        Reesenews.views.mainView.setActiveItem(
                 Reesenews.views.submissionsView
     );
    },
    'about': function(options){
    	Ext.apply(Reesenews.views, {
    		aboutView: new Reesenews.views.AboutView()
        });
    	Reesenews.views.mainView.items.add(Reesenews.views.aboutView);
        Reesenews.views.mainView.setActiveItem(
                 Reesenews.views.aboutView
     );
    },
    'return':function(options){
    	 Reesenews.views.mainView.setActiveItem(
    	         Reesenews.views.articleListView
      );
    }
});

Reesenews.controllers.articleController = Ext.ControllerManager.get('ArticleController');